@extends('layouts.app')

@section('title')
    Article
@endsection

@section('content')
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">添加文章</div>
                <div class="panel-body">
                    <form class="form-horizontal" method="POST" @if ($data['mode'] == "create") action="{{ url('/article/store') }}" @else action="{{ url('/article/update/'.$data->id) }}" @endif>
                        {!! csrf_field() !!}
                        {{ method_field('POST') }}
                        <div class="form-group{{ $errors->has('name') ? ' has-error' : '' }}">
                            <label class="col-md-2 control-label">文章标题</label>

                            <div class="col-md-8">
                                <input type="text" class="form-control" name="name" @if(isset($data->name)) value="{{ $data->name }}" @else value="{{ old('name') }}" @endif >

                                @if ($errors->has('name'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('name') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                            
                        <div class="form-group{{ $errors->has('summary') ? ' has-error' : '' }}">
                            <label class="col-md-2 control-label">文章摘要</label>

                            <div class="col-md-8">
                                <textarea class="form-control" name="summary" rows="5">@if(isset($data->summary)) {{ $data->summary }} @else {{ old('summary') }} @endif</textarea>

                                @if ($errors->has('summary'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('summary') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>
                            
                        <div class="form-group{{ $errors->has('description') ? ' has-error' : '' }}">
                            <label class="col-md-2 control-label">文章内容</label>

                            <div class="col-md-8">
                                <textarea class="form-control" name="description" rows="3">@if(isset($data->description)) {{ $data->description }} @else {{ old('description') }} @endif</textarea>

                                @if ($errors->has('description'))
                                    <span class="help-block">
                                        <strong>{{ $errors->first('description') }}</strong>
                                    </span>
                                @endif
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-6 col-md-offset-2">
                                <button type="submit" class="btn btn-primary">
                                    <i class="fa fa-btn fa-user"></i>发布文章
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection
